package com.jgzx.controller;


import com.jgzx.common.R;
import com.jgzx.domain.ListVO;
import com.jgzx.domain.dto.IdDTO;
import com.jgzx.domain.dto.UserDTO;
import com.jgzx.domain.vo.UserVO;
import com.jgzx.security.annotation.PreAuthorize;
import com.jgzx.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "用户个人信息")
@RequestMapping("/UserInfo")
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("用户列表")
    @PreAuthorize(hasPermi = "service:UserInfo:listAll")
    @PostMapping("/listAll")
    public R<ListVO<UserVO>> listAll() {
        return userService.listAll();
    }

    @ApiOperation("用户详情")
    @PreAuthorize(hasPermi = "service:UserInfo:findUser")
    @PostMapping("/findUser")
    public R<UserVO> findUser(IdDTO idDTO){
        return userService.findUser(idDTO);
    }

    @ApiOperation("新增用户")
    @PreAuthorize(hasPermi = "service:UserInfo:addUser")
    @PostMapping("/addUser")
    public R<UserVO> AddUser(UserDTO userDTO) {
        return userService.AddUser(userDTO);
    }

    @ApiOperation("删除用户")
    @PreAuthorize(hasPermi = "service:UserInfo:deleteUser")
    @PostMapping("/deleteUser")
    public R DeleteUser(long userid) {
        return userService.DeleteUser(userid);
    }

    @ApiOperation("更新用户信息")
    @PreAuthorize(hasPermi = "service:UserInfo:updateUser")
    @PostMapping("/updateUser")
    public R<UserVO> UpdateUser(UserDTO userDTO) {
        return userService.UpdateUser(userDTO);
    }
}
